<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class PromoterModel extends Model
{
    protected $table = 'think_promoter';
    protected $primaryKey = "id";
    protected $fillable = ['id','userName','passWord','groupId','groupTitle','groupName','PID','groupQQ','isAction','joinTime'];
    public $timestamps = false;//关闭laravel自带更新created_at,updated_at,deleted_at的操作

    public function getList()
    {//分页获取列表
        $columns = ['id','userName','passWord','groupId','groupTitle','groupName','PID','groupQQ','isAction','joinTime'];
        $res = self::where('id','>','1')->paginate(2,$columns);
        //$res->links();
        //dd($res);
        if($res)
        {
            return $res;
        }
        return false;
    }
    public function saveInfo($data)
    {//添加一个信息
        $res = self::create($data);
        if($res)
        {
            return $res;
        }
        return false;

    }
    public function getPromoter($id)
    {//获取单个信息
        $res = self::find($id);
        if($res)
        {
            return $res;
        }
        return false;

    }
    public function getInfoByQun($qun)
    {//根据群名称获取用户信息
        $res=self::where('groupId','=',$qun)->get();
        if($res)
        {
            return $res;
        }
        return false;

    }
    public function getPromoterByGroupId($groupId)
    {

    }
    public function updataInfo($data)
    {//更改一个信息
        $res=self::where(['id'=>$data['id']])->update($data);
        if($res)
        {
            return $res;
        }
        return false;
    }
    public function delInfo($id)
    {//删除一个信息
        $res=self::where(['id'=>$id])->delete();
        if($res)
        {
            return $res;
        }
        return false;
    }




}
